package com.qf;

import com.qf.bean.SysUserInfo;
import com.qf.service.SysUserInfoService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.UUID;

/*
 *  @author Administrator
 *  @version V1.0
 *  @Project smartdeviceplatgorm
 *  @Package com.qf
 *  @Description
 *  @Date2022/3/14 0014 19:37
 */
@RunWith(SpringJUnit4ClassRunner.class)//以spring和junit整合的方式来运行
@ContextConfiguration("classpath:applicationContext.xml")//指定配置文件的位置, spring会自动加载这个文件
public class test {
    private SysUserInfoService userInfoService;
    @Autowired
    public void setSysUserInfoService(SysUserInfoService userInfoService) {
        this.userInfoService = userInfoService;
    }
    @Test
    public void testAdd() {
        SysUserInfo sysUserInfo = new SysUserInfo();
        sysUserInfo.setUsername("admin");
        sysUserInfo.setPassword("123456");
        sysUserInfo.setName("aaa");
        sysUserInfo.setPhone("13643345344");
        sysUserInfo.setEmail("admin@163.com");
        sysUserInfo.setSex(1);
        userInfoService.addSysUserInfo(sysUserInfo);
    }

    @Test
    public void login() {
        SysUserInfo admin = userInfoService.findByUsernameAndPassword("admin", "123456");
        System.err.println("登录成功");
    }

    @Test
    public void UUID() {
        String deviceId = UUID.randomUUID().toString().replace("-","");
        System.err.println(deviceId);
    }

}
